package com.hykj.xxltest.utils;//package com.hykj.hbr.utils;
//
//import cn.jiguang.common.ClientConfig;
//import cn.jiguang.common.resp.APIConnectionException;
//import cn.jiguang.common.resp.APIRequestException;
//import cn.jpush.api.JPushClient;
//import cn.jpush.api.push.PushResult;
//import cn.jpush.api.push.model.Options;
//import cn.jpush.api.push.model.Platform;
//import cn.jpush.api.push.model.PushPayload;
//import cn.jpush.api.push.model.audience.Audience;
//import cn.jpush.api.push.model.notification.AndroidNotification;
//import cn.jpush.api.push.model.notification.Notification;
//import com.hykj.hbr.config.Config;
//import org.apache.log4j.Logger;
//
//public class PushUtil {
//
//    private static Logger logger = Logger.getLogger(PushUtil.class);
//
//    public static void main(String[] args) throws InterruptedException {
//       for (int i=0;i<1;i++) {
//            Thread.sleep(10000);
//            push("hello "+i, 3, 10, 0,null);
//        }
//
//
//    }
//
//    public static void push(String meassge,Integer cinemaId,Integer orderId,Integer type,String data) {
//        JPushClient jpushClient = new JPushClient(Config.MASTER_SECRET, Config.JPUSH_APP_KEY, null, ClientConfig.getInstance());
//        PushPayload payload = PushPayload.newBuilder()
//                .setPlatform(Platform.all())
//                /**
//                 * 单独添加用户推送
//                 */
//                .setAudience(Audience.tag("cinemaId"+cinemaId))
//
//                .setNotification(
//                        Notification.newBuilder()
//                                .setAlert(meassge)
//                                .addPlatformNotification(AndroidNotification.newBuilder()
//                                        .addExtra("type", type)
//                                        .addExtra("orderId", orderId)
//                                        .addExtra("data", data)
//                                        .build())
//                                .build()
//                )
//                .setOptions(Options.newBuilder()
//                        .setApnsProduction(true)
//                        .build())
//                .build();
//
//        try {
//            PushResult result = jpushClient.sendPush(payload);
//            logger.info("Got result - " + result);
//        } catch (APIConnectionException e) {
//            // Connection error, should retry later
//            logger.error("Connection error, should retry later", e);
//        } catch (APIRequestException e) {
//            // Should review the error, and fix the request
//            logger.error("Should review the error, and fix the request", e);
//            logger.info("HTTP Status: " + e.getStatus());
//            logger.info("Error Code: " + e.getErrorCode());
//            logger.info("Error Message: " + e.getErrorMessage());
//        }
//    }
//}
